part of '../repository.dart';

class AssetUseCaseDto extends Equatable {
  const AssetUseCaseDto({
    required this.example,
    required this.translation,
  });

  final String example;
  final String translation;

  @override
  List<Object?> get props {
    return [
      example,
      translation,
    ];
  }

  static const _exampleKey = 'example';
  static const _translationKey = 'translation';

  AssetLexicalItemUseCase toAssetUseCase() {
    return AssetLexicalItemUseCase(
      exampleMarkdown: example,
      translationMarkdown: translation,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _exampleKey: example,
      _translationKey: translation,
    };
  }

  factory AssetUseCaseDto.fromAssetUseCase(AssetLexicalItemUseCase useCase) {
    return AssetUseCaseDto(
      example: useCase.exampleMarkdown,
      translation: useCase.translationMarkdown,
    );
  }

  factory AssetUseCaseDto.fromJson(Map<String, dynamic> json) {
    return AssetUseCaseDto(
      example: json[_exampleKey],
      translation: json[_translationKey],
    );
  }
}
